<template>
    <!-- <view class="uni-shadow tem">
        <view class="u-flex u-row-between">
            <text class="font-bold">企业名称</text>
            <u-button class="uni-look-btn" type="warning" :plain="true" shape="circle" text="" @tap="detail">
                <text class="u-font-24">查看</text>
            </u-button>
        </view>
        <u-row class="u-flex u-flex-wrap">
            <u-col v-for="(item,index) in projectData.list" :key="index" :span="index==projectData.list.length-1?12:6"
                class="u-m-t-20 u-font-26 col">
                <text class="u-m-r-20 uni-dec-color">{{item.title}}</text>
                <u--text v-if="item.type=='phone'" mode="phone" :text="item.value" size="13" type="primary"></u--text>
                <text v-else>{{item.value}}</text>
            </u-col>
        </u-row>
    </view> -->
    <view class="uni-shadow item" @tap.stop="detail">
        <u-row class="u-flex u-flex-wrap">
            <u-col v-for="(item,index) in list" :key="index" 
                :span="index==0||index==list.length-1?12:6" 
                :class="['u-font-26','col',index==0?'u-m-b-10':'u-m-t-20']">
                <text :class="['u-m-r-20','u-line-1',index==0?'u-font-28 font-bold':'uni-dec-color']" 
                    @longtap="longTap(item.title)">{{item.title}}
                </text>
                <uni-phone v-if="item.type=='phone'" :phone="item.value" :size="13" />
                <text v-else class="u-line-1" @longtap="longTap(item.value)"
                    :style="{maxWidth:index==list.length-1?'78%':'45%'}" >{{item.value}}
                </text>
            </u-col>
        </u-row>
        <!-- 提示组件 -->
        <u-toast ref="uToast"></u-toast>
    </view>

</template>


<script>
export default {
    name: 'projectItem',
    title: '项目列表',
    props:{
        listItem:{
            type: Object,
            default(){
                return {}
            }
        }
    },

    data(){
        return {
            list: [
                { fied:'xmmc', title:'项目名称', value:'' },
                { fied:'xmtype', title:'项目类型', value:'暂无数据' },
                { fied:'districtName', title:'所属区划', value:'暂无数据' },
                { fied:'jsjd', title:'项目状态', value:'暂无数据' },
                { fied:'constructionname', title:'施工单位', value:'暂无数据' },
                { fied:'contactname', title:'项目负责人', value:'暂无数据' },
                { fied:'contactphone', title:'联系电话', value:'10086', type:'phone' },
                { fied:'xmdz', title:'项目地址', value:'暂无数据' },
            ]
        }
    },

    created() {
        // 处理数据
        this.list.map((v,i)=>{
            for(let key in this.listItem){
                if( v.fied == key ){
                    if( v.fied == 'xmmc' ){
                        v.title = this.listItem[key]
                    }else{
                        v.value = this.listItem[key]
                    }
                }
            }
        })
    },

    methods: {
        // 长按事件
        longTap(value){
            this.$refs.uToast.show({
                message: value,
                type: 'default',
                duration: 3000
            })
        },

        // 详情
        detail(){
            uni.navigateTo({
                url: '/pages/project-bag/detail?id='+this.listItem.id
            })
        }
    },
}
</script>


<style scoped lang="scss">
    .item{
        .col{
            flex-direction: row;
        }
    }
</style>